package com.fencing_squad.homo.util;

import com.fencing_squad.homo.util.function.FunctionInt;
import com.fencing_squad.homo.util.function.PageSliding;
import ohos.agp.components.PageSlider;

public class CustomListener {
    public static PageSlider.PageChangedListener getPageListener(FunctionInt chosen, FunctionInt stateChanged, PageSliding pageSliding) {
        return new PageSlider.PageChangedListener() {
            @Override
            public void onPageSliding(int i, float v, int i1) {
                if (pageSliding != null) {
                    pageSliding.func(i, v, i1);
                }
            }

            @Override
            public void onPageSlideStateChanged(int i) {
                if (stateChanged != null) {
                    stateChanged.func(i);
                }
            }

            @Override
            public void onPageChosen(int i) {
                if (chosen != null) {
                    chosen.func(i);
                }
            }
        };
    }
}
